package com.mathassistant.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.shared.SimpleEventBus;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DockLayoutPanel;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.RootLayoutPanel;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.mathassistant.client.view.HeaderView;
import com.mathassistant.client.view.TopicMainView;

public class MathAssistantMVP extends Composite implements EntryPoint {

	private static MathAssistantMVPUiBinder uiBinder = GWT
			.create(MathAssistantMVPUiBinder.class);
	@UiField
	HeaderView headerView;
	@UiField
	HTMLPanel footerView;
//	@UiField
//	ScrollPanel topicView;
	@UiField 
	HTMLPanel titleContentView;
	@UiField 
	ScrollPanel contentView;
	@UiField TopicMainView topicView;


	public HTMLPanel getFooterView()
	{
		return footerView;
	}
	public TopicMainView getTopicView() {
		return topicView;
	}

	
	public ScrollPanel getContentView(){
		return contentView;
	}

	public HTMLPanel getTitleContentView(){
		return titleContentView;
	}
	
	private static MathAssistantMVP singleton;
	private Boolean isLogin = false;
	
	RootLayoutPanel root;

	private SimpleEventBus eventBus = new SimpleEventBus();

	interface MathAssistantMVPUiBinder extends
			UiBinder<DockLayoutPanel, MathAssistantMVP> {
	}

	public MathAssistantMVP() {
		initWidget(uiBinder.createAndBindUi(this));
		singleton = this;
	}

	public static MathAssistantMVP get() {
		return singleton;
	}
	
	public Boolean getIsLogin(){
		return isLogin;
	}
	public void setIsLogin(Boolean islogin){
		this.isLogin = islogin;
	}
	
	@Override
	public void onModuleLoad() {
		// TODO Auto-generated method stub		
		singleton = this;
        createUI();
	}
	
	public void createUI() {
		DockLayoutPanel outer = uiBinder.createAndBindUi(this);
		root = RootLayoutPanel.get();
		root.clear();
		root.add(outer);

		AppController appViewer = new AppController(eventBus, singleton);
		appViewer.go();

	}
}
